package com.itheima.service.impl;

import com.itheima.common.Com.Order;
import com.itheima.common.pojo.PageInfo;
import com.itheima.mapper.OrderMapper;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public Boolean update(Order order) {
        Boolean update = orderMapper.update(order);
        return update;

    }

    @Override
    public PageInfo<Order> page(String beginTime, String endTime, String number, Integer page, Integer pageSize) {

        PageInfo<Order> pageInfo = new PageInfo<Order>();
        Integer start = (page - 1) * pageSize;

        List<Order> page1 = orderMapper.page(beginTime, endTime, number, start, pageSize);

        pageInfo.setRecords(page1);
        pageInfo.setCurrent(page);
        pageInfo.setSize(pageSize);
        long count = orderMapper.count(number);
        pageInfo.setTotal(count);
        return pageInfo;


    }
}
